package com.sws.weixin.mapper;


import com.sws.weixin.entity.TemplateInfo;
import com.sws.wxtemplate.domain.WechatTemplate;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface Template2Mapper {

        @Insert("INSERT INTO ry_wx_template(template_id, title, primary_industry, deputy_industry, content, example) " +
                "VALUES(#{templateId}, #{title}, #{primaryIndustry}, #{deputyIndustry}, #{content}, #{example}) " +  // 使用 #{templateId}
                "ON DUPLICATE KEY UPDATE title=VALUES(title), content=VALUES(content)")
        void insertOrUpdate(TemplateInfo template);

        @Delete("DELETE FROM ry_wx_template WHERE template_id = #{templateId}")
        void deleteByTemplateId(String templateId);



        @Select("SELECT * FROM ry_wx_template WHERE template_id = #{templateId}")
        WechatTemplate selectByWxTemplateId(String templateId);


        @Delete("DELETE FROM ry_wx_template")
        void deleteTemplatAll();
}
